/*
 * The Master Client
 */
package gui;

import client.Startup;
import config.Content;
import handler.MasterClientHandler;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JScrollPane;

/**
 * Administrative client's GUI.
 * @author Joep Kemperman, Kay van Bree
 */
public class MasterClient extends Client {
	
	private QueryPanel queryPanel;
    private UserAdministrationPanel useradministrationPanel;
	private JMenu menuAdmin;
	private JScrollPane queryScrollPane;
	public JMenuItem itemAddQuery;
	
	/**
	 * Constructor
	 * @param name Name of client
	 */
	public MasterClient(String name){
		super(name);
		queryPanel = new QueryPanel();
		queryScrollPane = new JScrollPane(queryPanel);
		queryScrollPane.getVerticalScrollBar().setUnitIncrement(10);
		queryScrollPane.getHorizontalScrollBar().setUnitIncrement(6);
		useradministrationPanel = new UserAdministrationPanel();
		this.clientHandler = new MasterClientHandler(this);
		addAdminMenu();
		init();
		validate();
	}
	
	/**
	 * Add the admin menu to the menubar
	 * @author Kay van Bree
	 */
	private void addAdminMenu(){
		menuAdmin = new JMenu("Admin");
		itemAddQuery = new JMenuItem("Add Query");
		itemAddQuery.addActionListener(clientHandler);
		menuAdmin.add(itemAddQuery);
		menu.add(menuAdmin);
	}
	
	/**
	 * Initializes all attributes
	 */
	private void init() {
		tabbedPane.addTab("Query Panel", queryScrollPane);
		tabbedPane.addTab("UserManagement Panel", useradministrationPanel);
	}
	
	@Override
	public void run() {
		super.run();
		Content.log.println("Run, masterclient, run!");
	}
}
